package com.tw.controller;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

import javax.servlet.ServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class CommonController {

	@PreAuthorize("hasRole('RRR')")
	@RequestMapping(value={"/","/home"})
    public String index() {
        return "home/home";
    }
	
	@RequestMapping("/login")
	public String login(Model model) {
		System.out.println("to login----");
		return "login/login";
	}
	
	@RequestMapping("/thymeleaf")
	public String test(Map<String,Object> map,ServletResponse response) throws UnsupportedEncodingException, IOException{
		map.put("name", "test");
		System.out.println("thymeleaf----");
		return "thymeleaf/hello2";
	}
	
	/**
	 * 功能描述：角色管理
	 * CHENY037 2017年11月29日
	 * @return
	 */
	@RequestMapping("/roleManage")
	@PreAuthorize("hasRole('ROLE_MANAGE')")
	public String roleManage(){
		return "home/role";
	}
	
}
